package com.learn.mvc.handler;

import com.learn.mvc.entity.President;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class PresidentHandler {

    Logger logger = LoggerFactory.getLogger(this.getClass());
    @RequestMapping("/save/president")
    public String saveEmail(
            @Validated President president,
            BindingResult bindingResult) {

        if(bindingResult.hasErrors()) {
            return "error";
        }


        logger.debug(president.toString());

        return "target";
    }

}
